<template>
    <el-row :gutter="20">
        <el-alert
            title="没有推送消息"
            type="success"
            v-if="push.length===0"
            close-text="知道了"
            show-icon>
        </el-alert>
        <el-col :span="10" :offset="2" v-else v-for="(item,index) in push" :key="index">
            <push-item @remove="remove(index)" :push="item"></push-item>
        </el-col>
    </el-row>
</template>

<script>
    import PushItem from './pushItem'
    import { mapActions } from 'vuex'

    export default {
        name: 'globalPost',
        components: {
            PushItem
        },
        data () {
            return {
                push: []
            }
        },
        mounted () {
            this.action(this.pushAction(), data => {
                this.push = data.data
            })
            this.$notify({
                title: '提示',
                message: '注意：您查看过的推送消息将在10分钟后清除',
                duration: 3000
            })
        },
        methods: {
            ...mapActions('post', {
                pushAction: 'push'
            }),
            remove (index) {
                this.push.splice(index, 1)
            }
        }
    }
</script>

<style scoped>

</style>
